<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>对象</title>
	<!--<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>-->
</head>
<body>
<script>
	`use strict`;
	//JavaScript对象是无序的集合数据类型,它由若干键值对组成
	//JavaScript对象用于描述现实世界的某个对象
	//比如描述小明
	var xiaoming = {
		name:'小明',
		age:23,
		gender:'男',
		school:"Beijing University",
		score:90
	}
	console.log("xiaoming.name:" + xiaoming.name);
	console.log("xiaoming.age:" + xiaoming.age );
	//访问未定义的属性会返回undefined；
	console.log("xiaoming.parent:" + xiaoming.parent);

	//JavaScript 对象是动态类型，可以自由的添加/删除对象的属性
	//给小明添加height属性
	xiaoming.height = 180;
	console.log("小明：" + xiaoming);
	//删除小明的score属性
	delete xiaoming.score;
	console.log("小明：" + xiaoming);

	//判断小明对象是否由某一个属性
	var hasToString = "toString" in xiaoming;
	console.log("小明是否由toString属性:" + hasToString);
	var hasName1 = xiaoming.hasOwnProperty("name");
	var hasName2 = xiaoming.hasOwnProperty("toString");
 	console.log("小明是否由name属性(hasOwnProperty判断):" + hasName1);
 	console.log("小明是否由toString属性(hasOwnProperty判断):" + hasName2)


</script>
</body>
</html>